package com.heima.wemedia.controller;

import com.heima.model.dtos.PageResponseResult;
import com.heima.model.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.common.GetUserId;
import com.heima.wemedia.service.WmMaterialService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 张一恒
 * @version 1.0
 * @description: v1 自媒体接口
 * @date 2023/1/11 16:07
 */
@RestController
@Slf4j
@RequestMapping("/api/v1/material")
public class WmMaterialController {

    @Autowired
    private WmMaterialService wmMaterialService;

    /**
     * @description 上传图片接口
     * @param file
     * @return com.heima.model.dtos.ResponseResult
     * @author 31115
     * @date 2023/1/11 16:10
     */
    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(@RequestParam("multipartFile") MultipartFile file){

        Integer userId = GetUserId.getUserId();
        return wmMaterialService.uploadPicture(userId,file);
    }


    /**
     * @description 素材列表查询
     * @param dto 
     * @return com.heima.model.dtos.PageResponseResult
     * @author 31115 
     * @date 2023/1/11 21:17
     */
    @PostMapping("/list")
    public PageResponseResult filedList(@RequestBody WmMaterialDto dto){
        Integer userId = GetUserId.getUserId();
        return wmMaterialService.filedList(userId,dto);
    }

}
